﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace drawing_print.util
{
    /// <summary>
    /// 图片处理流程步骤
    /// </summary>
    class Procedures
    {

        /// <summary>
        /// 一个图片的处理流程记录
        /// </summary>
        public List<Procedure> procedures;

        public Procedures()
        {
            procedures = new List<Procedure>();
        }
        /// <summary>
        /// 添加一个处理过程
        /// </summary>
        /// <param name="procedure">图片处理过程</param>
        public void add(Procedure procedure)
        {
            this.procedures.Add(procedure);
        }

        /// <summary>
        /// 删除最后一个流程
        /// </summary>
        /// <returns>最后一个流程</returns>
        public Procedure last()
        {
            // 返回最后一个
            return this.procedures[this.procedures.Count() - 1];
        }

        /// <summary>
        /// 删除最后一个流程，并返回删除后的最后一个流程
        /// </summary>
        /// <returns>最后一个流程</returns>
        public Procedure removeLast()
        {
            // 删除最后一个
            int last_index = this.procedures.Count() - 1;
            if (last_index > 0)
            {
                this.procedures.RemoveAt(last_index);
            }
            // 返回最后一个
            return this.procedures[this.procedures.Count() - 1];
        }
        /// <summary>
        /// 获取前一个过程
        /// </summary>
        /// <returns></returns>
        public Procedure front()
        {
            int last_index = this.procedures.Count() - 1;
            if (last_index - 2 >= 0)
            {
                return this.procedures[last_index - 2];
            }
            else
            {
                return this.procedures[0];
            }
        }
        /// <summary>
        /// 获取第一个
        /// </summary>
        /// <returns>第一个步骤</returns>
        public Procedure first()
        {
            return this.procedures[0];
        }


    }
}
